<template>
  <div class="screen-full">
    <i :class="isFull ? 'el-icon-close' : 'el-icon-full-screen'" @click="toggleFullScreen" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  data() {
    return {
      isFull: false
    }
  },
  created() {
    // ESC会改变当前的全屏状态
    // screenfull是插件，它自带事件监听 on
    // screenfull.isFullscreen ：插件自带的属性，表示当前是否处于全屏状态
    screenfull.on('change', () => {
      // console.log('当前是否是全屏', screenfull.isFullscreen)
      this.isFullScreen = screenfull.isFullscreen
      this.isFull = screenfull.isFullscreen
    })
  },
  methods: {
    toggleFullScreen() {
      screenfull.toggle()
    }
  }
}
</script>

<style lang="scss" scoped>
.screen-full {
  display: inline-block;
  color: #ffffff;
  font-size: 22px;
  margin-right: 20px;
}
</style>
